package com.open.ssm.modules.trade.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.open.ssm.common.annotation.Log;
import com.open.ssm.common.core.controller.BaseController;
import com.open.ssm.common.core.domain.AjaxResult;
import com.open.ssm.common.enums.BusinessType;
import com.open.ssm.modules.trade.domain.LnTradeRec;
import com.open.ssm.modules.trade.service.ILnTradeRecService;
import com.open.ssm.common.utils.poi.ExcelUtil;
import com.open.ssm.common.core.page.TableDataInfo;

/**
 * 充电订单Controller
 * 
 * @author wangpf
 * @date 2021-08-18
 */
@RestController
@RequestMapping("/modules/trade")
public class LnTradeRecController extends BaseController
{
    @Autowired
    private ILnTradeRecService lnTradeRecService;

    /**
     * 查询充电订单列表
     */
    @PreAuthorize("@ss.hasPermi('modules:trade:list')")
    @GetMapping("/list")
    @CrossOrigin(origins="http://wx.lnevcg.com:80")
    public TableDataInfo list(LnTradeRec lnTradeRec)
    {
        startPage();
        List<LnTradeRec> list = lnTradeRecService.selectLnTradeRecList(lnTradeRec);
        return getDataTable(list);
    }

    /**
     * 导出充电订单列表
     */
    @PreAuthorize("@ss.hasPermi('modules:trade:export')")
    @Log(title = "充电订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LnTradeRec lnTradeRec)
    {
        List<LnTradeRec> list = lnTradeRecService.selectLnTradeRecList(lnTradeRec);
        ExcelUtil<LnTradeRec> util = new ExcelUtil<LnTradeRec>(LnTradeRec.class);
    	return util.exportEasyExcel(list, "充电订单数据");
    }

    /**
     * 获取充电订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('modules:trade:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(lnTradeRecService.selectLnTradeRecById(id));
    }

    /**
     * 新增充电订单
     */
    @PreAuthorize("@ss.hasPermi('modules:trade:add')")
    @Log(title = "充电订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LnTradeRec lnTradeRec)
    {
        return toAjax(lnTradeRecService.insertLnTradeRec(lnTradeRec));
    }

    /**
     * 修改充电订单
     */
    @PreAuthorize("@ss.hasPermi('modules:trade:edit')")
    @Log(title = "充电订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LnTradeRec lnTradeRec)
    {
        return toAjax(lnTradeRecService.updateLnTradeRec(lnTradeRec));
    }

    /**
     * 删除充电订单
     */
    @PreAuthorize("@ss.hasPermi('modules:trade:remove')")
    @Log(title = "充电订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(lnTradeRecService.deleteLnTradeRecByIds(ids));
    }
}
